﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TCCUIControls
{
    public partial class UIChip : UserControl
    {
        private int m_Padding = 10;
        private int m_Margin = 5;

        public UIChip()
        {
            InitializeComponent();
        }

        public void InitializeUI(List<UserControl> uiControls)
        {
            int width = m_Margin;
            int height = m_Margin;

            int x = m_Margin;
            int y = m_Margin;

            foreach (UserControl userControl in uiControls)
            {
                userControl.Left = x;
                userControl.Top = y;
                x += m_Padding + userControl.Width;
                width += m_Padding + userControl.Width;
                height = userControl.Height;

                this.Controls.Add(userControl);
            }

            width += m_Margin;
            height += 2 * m_Margin;

            this.Width = width;
            this.Height = height;

            this.Invalidate(true);
        }

        private void UIChip_Load(object sender, EventArgs e)
        {
        }

        private void UIChip_Resize(object sender, EventArgs e)
        {
            this.Invalidate(true);
        }

        private void UIChip_Enter(object sender, EventArgs e)
        {
            this.Invalidate(true);
        }
    }
}
